<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('管理员列表')" />
    <th:block th:include="include :: bootstrap-select-css"/>
</head>
<body>
<div class="container-div">
    <div class="row">
        <div class="container-div">
            <div class="row">
                <div class="col-sm-12 search-collapse">
                    <form id="admin-form">
                        <div class="select-list">
                            <ul>

                                <li>
                                    <label>BotQQ： </label>
                                    <input id="botUid" name="botUid" type="text" placeholder="BotQQ"
                                           />
                                </li>

                                <li>
                                    <label>管理员QQ： </label>
                                    <input id="botAdminUid" name="botAdminUid" type="text" placeholder="管理员QQ"
                                           />
                                </li>

                                <li>
                                    <label>权限等级：</label>
                                    <select id="botPrivilege" name="botPrivilege">
                                    <option value="">所有</option>
                                        <option  th:each="k:${keys}" th:value="${k.key}" th:text="${k.value}"></option>
                                    </select>
                                </li>

                                <li>
                                    <a class="btn btn-primary btn-rounded btn-sm" onclick="searchPre()"><i
                                            class="fa fa-search"></i>&nbsp;搜索</a>
                                    <a class="btn btn-warning btn-rounded btn-sm" onclick="resetPre()"><i
                                            class="fa fa-refresh"></i>&nbsp;重置</a>
                                </li>
                            </ul>
                        </div>
                    </form>
                </div>

                <div class="btn-group-sm" id="toolbar" role="group">
                    <a class="btn btn-primary btn-rounded btn-sm" onclick="$.operate.add()">
                        <i class="fa fa-remove"></i> 添加
                    </a>
                </div>

                <div class="col-sm-12 select-table table-striped">
                    <table id="bootstrap-table"></table>
                </div>
            </div>
        </div>
    </div>
</div>

<th:block th:include="include :: footer" />
<th:block th:include="include :: bootstrap-select-js"/>
<script th:inline="javascript">
    var prefix = ctx + "bot/admin"
    $(function() {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add/{id}",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove/{id}",
            modalName: "管理员",
            sortOrder: "desc",
            escape: true,
            showPageGo: true,
            rememberSelected: true,
            columns: [
                {
                    field: 'state',
                    radio: true
                },
                {
                    field: 'uid',
                    title: 'uid'
                },
                {
                    field: 'botUid',
                    title: '机器人QQ'
                },
                {
                    field: 'botAdminUid',
                    title: '管理员QQ'
                },
                {
                    field: 'botPrivilege',
                    title: '权限等级'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        if (row.uid !== 0) {
                            var actions = [];
                            actions.push('<a class="btn btn-success btn-xs " href="javascript:void(0)" onclick="$.operate.edit(' + row.uid + ')"><i class="fa fa-edit"></i>修改</a> ');
                            actions.push('<a class="btn btn-danger btn-xs " href="javascript:void(0)" onclick="$.operate.remove(' + row.uid + ')"><i class="fa fa-trash"></i>删除</a>');
                            return actions.join('');
                        }
                    }
                }]
        };
        $.table.init(options);
    });

     function queryParams(params) {
        return $.table.queryParams(params);
    }

    function searchPre() {
        $.table.search('admin-form', 'bootstrap-table');
    }

    function resetPre() {
        $("#admin-form")[0].reset();
        $.table.search('admin-form', 'bootstrap-table');
    }
</script>

</body>
</html>